<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const xhr = new XMLHttpRequest();
      console.log(xhr.readyState); //0
      xhr.open("GET", "http://127.0.0.1:8081/video");
      console.log(xhr.readyState); //1
      xhr.responseType = "blob";
      // 状态切换
      xhr.onreadystatechange = function () {
        if (xhr.readyState === 3) {
          // 进度 onprogress
          console.log("数据下载中...");
        }
        if (xhr.readyState === 4) {
          // 通信结束 onload
          console.log("通信结束");
        }
        // console.log(xhr.readyState);
      };
      xhr.send();
    </script>
  </body>
</html>
